
import React, { useState } from 'react';
import type { FormProps } from 'antd';
import { Button, Form, Input, Row, Col, Modal } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
import OrgModal from "@/components/orgModal/idnex";
import "./index.less";
type FieldType = {
	username?: string;
	password?: string;

};
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
	console.log('Success:', values);
};
const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
	console.log('Failed:', errorInfo);
};
const Gitee: React.FC = () => {
	const [isModalOpen, setIsModalOpen] = useState(false);
	const orgFun = () => {
		setIsModalOpen(true);
	};

	const handleCancel = () => {
		setIsModalOpen(false);
	};
	const [orgNo, setOrgNo] = useState('');
	const [orgName, setOrgName] = useState('');
	const handleDataChange = (orgNo: any, orgName: any) => {
		setOrgNo(orgNo)
		setOrgName(orgName)

	};
	const [form] = Form.useForm()
	const handleOk = () => {
		console.log(orgNo)
		form.setFieldValue('orgName', orgName)
		setIsModalOpen(false);
	};

	return (
		<>
			<div className='formBox'>
				<Form
					name="basic"
					form={form}
					style={{ maxWidth: '600' }}
					initialValues={{ remember: true }}
					onFinish={onFinish}
					onFinishFailed={onFinishFailed}
					autoComplete="off"
				>
					<Row gutter={24}>
						<Col span={6} >
							<Form.Item
								label="参数名称"
								name="modelTitle"
							// rules={[{ required: true, message: '请输出参数名称!' }]}
							>
								<Input placeholder="请输入" />
							</Form.Item>
						</Col>
						<Col span={6} >
							<Form.Item
								label="参数标识"
								name="modelIdentify"
							// rules={[{ required: true, message: '请输入参数标识' }]}
							>
								<Input placeholder="请输入" />
							</Form.Item>
						</Col>
						<Col span={6} >
							<Form.Item
								label="所属机构"
								name="orgName"
							// rules={[{ required: true, message: '请输入参数标识' }]}
							>
								<Input
									placeholder="请选择"
									onClick={orgFun}
									style={{ cursor: "pointer" }}
									suffix={
										<SearchOutlined style={{ color: 'rgba(0,0,0,.45)' }} />
									}
								/>
							</Form.Item>
						</Col>
					</Row>
					<Form.Item label={null}>
						<Button type="primary" htmlType="submit" onClick={() => form.resetFields()}>
							重置
						</Button>
					</Form.Item>

				</Form>
				<Modal title="机构选择" open={isModalOpen} onOk={handleOk} onCancel={handleCancel} >
					<OrgModal onDataChange={handleDataChange} ></OrgModal>
				</Modal>
			</div >
		</>
	)

};

export default Gitee;
